package com.deepocean.controller;

import com.deepocean.common.entity.ResultEntity;
import com.deepocean.entity.process.ProcessEntity;
import com.deepocean.entity.process.ProcessRelationEntity;
import com.deepocean.service.IProcessService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/process")
public class ProcessEngineController {
    @Autowired
    @Qualifier("ProcessServiceImpl")
    IProcessService processService;

    @Autowired
    @Qualifier("ProcessServiceConfigImpl")
    IProcessService processServiceConfig;

    @PostMapping("/v1/processStart")
    public ResultEntity processStart(@RequestParam Double rawCoal) {
        return processService.processStart(rawCoal);
    }

    @PostMapping("/v1/processRelation")
    public ResultEntity processRelation(@RequestParam Double rawCoal, @RequestParam Integer craftType) {
        return processServiceConfig.processRelation(rawCoal, craftType);
    }

    @PostMapping("/v1/updateRelation")
    public ResultEntity updateRelation(@RequestBody List<ProcessRelationEntity> list) {
        return ResultEntity.success(processServiceConfig.updateRelation(list));
    }

    @PostMapping("/v1/addRelation")
    public ResultEntity addRelation(@RequestBody List<ProcessRelationEntity> list) {
        return ResultEntity.success(processServiceConfig.updateRelation(list));
    }
}
